<?php

namespace App\Filament\Resources\Comments\Schemas;

use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Schema;

class CommentForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                Select::make('post_id')
                    ->label('文章')
                    ->relationship('post', 'title')
                    ->required(),
                Select::make('user_id')
                    ->label('用户')
                    ->relationship('user', 'name'),
                Select::make('parent_id')
                    ->label('父级评论')
                    ->relationship('parent', 'id'),
                TextInput::make('author_name')
                    ->label('作者姓名'),
                TextInput::make('author_email')
                    ->label('作者邮箱')
                    ->email(),
                TextInput::make('author_url')
                    ->label('作者网址')
                    ->url(),
                TextInput::make('author_ip')
                    ->label('作者IP'),
                Textarea::make('content')
                    ->label('内容')
                    ->required()
                    ->columnSpanFull(),
                Select::make('status')
                    ->label('状态')
                    ->options(['pending' => '待审核', 'approved' => '已批准', 'spam' => '垃圾评论', 'trash' => '回收站'])
                    ->default('pending')
                    ->required(),
                Toggle::make('is_featured')
                    ->label('特色评论')
                    ->required(),
                TextInput::make('likes_count')
                    ->label('点赞数')
                    ->required()
                    ->numeric()
                    ->default(0),
            ]);
    }
}
